package com.skb.core.model;

import javax.persistence.*;
import java.io.Serializable;

@Entity
@Table(name = "accounts", catalog = "skbbank")
public class Account implements Serializable {

    @Id
    @Column(name = "number", nullable = false, unique = true, length = 24)
    private String number;

    @Column(name = "balance", nullable = false, precision = 10, scale = 2)
    private Double balance = 0.0d;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "username", nullable = false)
    private User user;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "segment_id")
    private Segment segment;

    public Account() {}

    public Account(String number) {
        this.number = number;
    }

    public Account(String number, Double balance) {
        this.number = number;
        this.balance = balance;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Segment getSegment() {
        return segment;
    }

    public void setSegment(Segment segment) {
        this.segment = segment;
    }
}
